'use strict';
import { action, observable, configure, runInAction } from 'mobx'

configure({ enforceActions: 'observed' });

class BaseStore {

    constructor(params) {
        this.loading = false
        this.error = { isError: '', errorMsg: '' };
    }

    @observable loading = false
    @observable error

    @action
    getRequest = async (url, query) => {
        this.loading = true
        const result = await Services.get(url, query)
        runInAction(() => {
            this.loading = false
        })
        // console.log('result', result)
        return result
    }

    @action
    postRequest = async (url, data) => {
        this.loading = true
        const result = await Services.post(url, data)
        runInAction(() => {
            this.loading = false
        })
        // console.log('result', result)
        return result
    }

}

export default BaseStore;
